<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="file" id="ipt" onchange="Files(this)">
</body>
<script src="https://cdn.bootcss.com/xlsx/0.11.5/xlsx.core.min.js"></script>
<script>
  function Files(soure) {
    // 获取传递过来的内容
    let file = soure.files[0]
    // 创建 FileReader示例
    let fl = new FileReader()
    // 读取文件
    fl.readAsBinaryString(file)
    // 文件读取成功时的回调函数
    fl.onload = (e) => {
      // 获取传递的表格
      let data = e.target.result
      // 以二进制流方式读取到整份excel表格对象 
      let workbook = XLSX.read(data, {
        type: 'binary'
      })
      // 存储获取到的数据
      let persons = []
      // 遍历每张表
      for (let sheet in workbook.Sheets) {
        if (workbook.Sheets.hasOwnProperty(sheet)) {
          persons = persons.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
          break;
        }
      }
      console.log(persons);
    }
  }
</script>

</html>